package com.heima.zuoye.day09.timu1;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

public class InputStreamTest {
    public static void main(String[] args) throws Exception {

        read1();
        System.out.println();
        System.out.println("===============");
        read2();
    }

    public static void read1() throws Exception {
        FileInputStream fis = new FileInputStream("D:/file01.txt");
        int num;
        while ((num = fis.read()) != -1) {
            System.out.print((char) num);
        }
        fis.close();
    }

    public static void read2() throws Exception {
        FileInputStream fis = new FileInputStream("D:/file01.txt");
        int num;
        byte[] bytes = new byte[1024];
        while ((num = fis.read(bytes)) != -1) {
            System.out.print(new String(bytes, 0, num));
        }
        fis.close();
    }
}
